import { _decorator, Component, Node, ProgressBar } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('HpManager')
export class HpManager extends Component {
    @property(ProgressBar)
    public progressBar: ProgressBar | null = null;
    /** 更新血条，参数为当前血量和最大血量 */
    public updateHealth(currentHp: number, maxHp: number) {
        if (this.progressBar) {
            this.progressBar.progress = Math.max(0, currentHp / maxHp); // 计算血量比例
        }
    }
}


